<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>👍TestNG一篇足以 | iworkh blog</title>
  
    <meta name="keywords" content=" test ">
  
  <meta name="description" content="👍TestNG一篇足以 | iworkh blog">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description" content="个人简介沐雨云楼，程序员一名。 喜欢研究技术，主要从事JAVA、微服务、大数据领域。 联系方式 QQ : 157162006 邮箱 :157162006@qq.com">
<meta property="og:type" content="website">
<meta property="og:title" content="关于">
<meta property="og:url" content="https://iworkh.gitee.io/blog/about/index.html">
<meta property="og:site_name" content="iworkh blog">
<meta property="og:description" content="个人简介沐雨云楼，程序员一名。 喜欢研究技术，主要从事JAVA、微服务、大数据领域。 联系方式 QQ : 157162006 邮箱 :157162006@qq.com">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-05-17T07:22:16.000Z">
<meta property="article:modified_time" content="2020-09-12T13:21:47.523Z">
<meta property="article:author" content="沐雨云楼">
<meta property="article:tag" content="iworkh">
<meta property="article:tag" content="沐雨云楼">
<meta property="article:tag" content="blog">
<meta name="twitter:card" content="summary">


<link rel="icon" href="/blog/img/iwork.svg">

<link href="/blog/css/style.css?v=1.0.1" rel="stylesheet">

<link href="/blog/css/hl_theme/atom-light.css?v=1.0.1" rel="stylesheet">

<link href="//cdn.bootcdn.net/ajax/libs/animate.css/4.1.0/animate.min.css" rel="stylesheet">
<link href="//cdn.bootcdn.net/ajax/libs/font-awesome/5.13.0/js/fontawesome.min.js" rel="stylesheet">

<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="/blog/js/jquery.autocomplete.min.js?v=1.0.1" ></script>
<script src="/blog/js/titleTip.js?v=1.0.1" ></script>

<script src="//cdn.bootcdn.net/ajax/libs/highlight.js/10.0.3/highlight.min.js"></script>
<script>
    hljs.initHighlightingOnLoad();
</script>

<script src="//cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>



<script src="//cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js" ></script>

<script src="/blog/js/iconfont.js?v=1.0.1" ></script>

<meta name="generator" content="Hexo 4.2.1"></head>
<div style="display: none">
  <input class="theme_disqus_on" value="false">
  <input class="theme_preload_comment" value="false">
  <input class="theme_blog_path" value="/blog">
</div>




<body>
<aside class="nav">
    <div class="nav-left">
        <a href="/blog/" class="avatar_target">
    <img class="avatar" src="/blog/img/iwork.svg" />
</a>
<div class="author">
    <span>沐雨云楼</span>
</div>

<div class="icon">
    
        
        <a title="github" href="https://gitee.com/iworkh" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-github"></use>
                </svg>
            
        </a>
        
    
        
        <a title="csdn" href="https://blog.csdn.net/u011622109" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-csdn"></use>
                </svg>
            
        </a>
        
    
        
        <a title="email" href="mailto:157162006@qq.com" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-email"></use>
                </svg>
            
        </a>
        
    
        
        <a title="qq" href="http://wpa.qq.com/msgrd?v=3&uin=157162006&site=qq&menu=yes" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-qq"></use>
                </svg>
            
        </a>
        
    
        
        <a title="kugou" href="https://www.kugou.com/" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-kugou"></use>
                </svg>
            
        </a>
        
    
        
        <a title="neteasemusic" href="https://music.163.com/" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-neteasemusic"></use>
                </svg>
            
        </a>
        
    
</div>



<a class="more-menus">更多菜单</a>


<ul>
    <li><div class="all active">全部文章<small>(85)</small></div></li>
    
        
            
            <li><div data-rel="手册"><i class="fold iconfont icon-right"></i>手册<small>(2)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="iworkh">iworkh<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="pgmanor">pgmanor<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="工具"><i class="fold iconfont icon-right"></i>工具<small>(16)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="git">git<small>(2)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="github">github<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="hexo">hexo<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="idea">idea<small>(2)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="markdowm">markdowm<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="maven">maven<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="有道云">有道云<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="java"><i class="fold iconfont icon-right"></i>java<small>(20)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="dao">dao<small>(6)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="jvm">jvm<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="test">test<small>(5)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="tools">tools<small>(3)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="并发">并发<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="微服务"><i class="fold iconfont icon-right"></i>微服务<small>(6)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="spring">spring<small>(2)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="springboot">springboot<small>(3)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="架构">架构<small>(2)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="大数据"><i class="fold iconfont icon-right"></i>大数据<small>(4)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="hadoop">hadoop<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="spark">spark<small>(3)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="web"><i class="fold iconfont icon-right"></i>web<small>(3)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="vue">vue<small>(2)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="db"><i class="fold iconfont icon-right"></i>db<small>(4)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="mysql">mysql<small>(3)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="redis">redis<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="ai">ai<small>(4)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="python"><i class="fold iconfont icon-right"></i>python<small>(8)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="tornado">tornado<small>(3)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="linux"><i class="fold iconfont icon-right"></i>linux<small>(2)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="docker">docker<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="nginx">nginx<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="windows">windows<small>(3)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="结构和算法">结构和算法<small>(8)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="面试">面试<small>(2)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="其他">其他<small>(1)</small></div>
                
            </li>
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
</ul>
<div class="left-bottom">
    <div class="menus">
    
    
    
    <a class="dynamic-menu " target="_blank"  href="https://pgmanor.gitee.io/blog/">pgmanor</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://www.iworkh.com/manualIt/Category/scopeDev/">iworkh</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://gitee.com/iworkh">gitee</a>
    
    </div>
    <div><a class="about  hasFriend  site_url"  href="/blog/about">关于</a><a style="width: 50%"  class="friends">友链</a></div>
</div>
<input type="hidden" id="iworkh_site_posts_number" value="85">
<input type="hidden" id="iworkh_site_word_count" value="197.8k">
<div style="display: none">
    <span id="busuanzi_value_site_uv"></span>
    <span id="busuanzi_value_site_pv"></span>
</div>

    </div>
    <div class="nav-right">
        <div class="friends-area">
    <div class="friends-title">
        友情链接
        <i class="back-title-list"></i>
    </div>
    <div class="friends-content">
        <ul>
            
            <li><a target="_blank" href="https://www.iworkh.com">iworkh</a></li>
            
            <li><a target="_blank" href="https://www.iworkh.com/download/share/">下载地址</a></li>
            
            <li><a target="_blank" href="http://yelog.org/">叶落阁</a></li>
            
        </ul>
    </div>
</div>
        <div class="title-list">
    <form onkeydown="if(event.keyCode === 13){return false;}">
        <input id="local-search-input" class="search" type="text" placeholder="in: 开头全文搜索" />
        <i class="cross"></i>
        <span>
            <label for="tagswitch">T:</label>
            <input id="tagswitch" type="checkbox" style="display: none" />
            <i id="tagsWitchIcon"></i>
        </span>
    </form>
    <div class="tags-list">
    
    <li class="article-tag-list-item">
        <a class="color3">ai</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">attr</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">aysnc</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">beanmap</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">bigdecimal</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">blog</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">chrome</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">dict</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">dll</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">docker</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">domain</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">fastjson</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">func</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">git</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">github</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">hadoop</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">hexo</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">idea</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">iworkh</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">jackson</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">java</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">jdni</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">jfinalshell</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">joplin</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">JPA</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">lock</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">markdowm</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">maven</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">mock</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">mq</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">mycat</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">mysql</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">nginx</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">notebook</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">plan</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">powermock</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">python</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">redis</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">rest</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">sharding-jdbc</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">spark</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">springboot</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">test</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">tool</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">tools</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">tornado</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">transactional</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">web</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">windows</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">wtforms</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">zookeeper</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">分库分表</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">分页</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">命令</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">工具</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">并发</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">序列化</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">微服务</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">性能分析</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">手册</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">有道云</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">标签</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">模板</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">百度云盘</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">结构和算法</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">计划</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">迁移</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">面试</a>
    </li>
    
    <div class="clearfix"></div>
</div>

    
    <div id="local-search-result">

    </div>
    
    <nav id="title-list-nav">
        
        <a id="top" class="手册 pgmanor "
           href="/blog/2020/12/15/redirect-to-pgmanor/"
           data-tag="迁移"
           data-author="沐雨云楼" >
            <span class="post-title" title="😘博客迁移">😘博客迁移</span>
            <span class="post-date" title="2020-12-15 23:47:55">2020/12/15</span>
        </a>
        
        <a id="top" class="手册 iworkh "
           href="/blog/2020/05/27/manual-iworkh/"
           data-tag="手册,iworkh"
           data-author="沐雨云楼" >
            <span class="post-title" title="iworkh所有手册">iworkh所有手册</span>
            <span class="post-date" title="2020-05-27 21:37:04">2020/05/27</span>
        </a>
        
        <a id="top" class="微服务 springboot "
           href="/blog/2020/06/27/spring_boot_all_resources/"
           data-tag="springboot"
           data-author="沐雨云楼" >
            <span class="post-title" title="Spring Boot全网优质教程汇总">Spring Boot全网优质教程汇总</span>
            <span class="post-date" title="2020-06-27 17:43:13">2020/06/27</span>
        </a>
        
        <a id="top" class="工具 "
           href="/blog/2020/06/22/baidu-pandisk-share/"
           data-tag="百度云盘"
           data-author="沐雨云楼" >
            <span class="post-title" title="百度云盘分享链接">百度云盘分享链接</span>
            <span class="post-date" title="2020-06-22 18:38:21">2020/06/22</span>
        </a>
        
        <a id="top" class="工具 "
           href="/blog/2020/06/21/tool_blogs_all/"
           data-tag="blog"
           data-author="沐雨云楼" >
            <span class="post-title" title="优质博客和文章">优质博客和文章</span>
            <span class="post-date" title="2020-06-21 20:02:14">2020/06/21</span>
        </a>
        
        <a id="top" class="java jvm "
           href="/blog/2020/06/04/java-online-analysis/"
           data-tag="性能分析"
           data-author="沐雨云楼" >
            <span class="post-title" title="JAVA线上故障排查全套路">JAVA线上故障排查全套路</span>
            <span class="post-date" title="2020-06-04 20:34:05">2020/06/04</span>
        </a>
        
        <a id="top" class="工具 idea "
           href="/blog/2020/05/31/jetbrains-idea/"
           data-tag="工具,idea"
           data-author="沐雨云楼" >
            <span class="post-title" title="idea使用技巧">idea使用技巧</span>
            <span class="post-date" title="2020-05-31 16:12:30">2020/05/31</span>
        </a>
        
        <a id="top" class="工具 有道云 "
           href="/blog/2020/05/18/youdao_config_edit/"
           data-tag="工具,有道云"
           data-author="沐雨云楼" >
            <span class="post-title" title="有道云配置修改">有道云配置修改</span>
            <span class="post-date" title="2020-05-18 21:37:04">2020/05/18</span>
        </a>
        
        <a id="top" class="web "
           href="/blog/2020/06/01/web-tools/"
           data-tag="web,tool"
           data-author="沐雨云楼" >
            <span class="post-title" title="前端常用工具">前端常用工具</span>
            <span class="post-date" title="2020-06-01 21:37:04">2020/06/01</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/10/25/tool-linux-jfinalshell/"
           data-tag="jfinalshell"
           data-author="沐雨云楼" >
            <span class="post-title" title="linux连接工具jfinalshell">linux连接工具jfinalshell</span>
            <span class="post-date" title="2020-10-25 10:24:59">2020/10/25</span>
        </a>
        
        <a  class="微服务 springboot "
           href="/blog/2020/10/06/spring-boot-multi-profiles/"
           data-tag="springboot"
           data-author="沐雨云楼" >
            <span class="post-title" title="springboot多环境配置打包">springboot多环境配置打包</span>
            <span class="post-date" title="2020-10-06 21:36:42">2020/10/06</span>
        </a>
        
        <a  class="web vue "
           href="/blog/2020/10/06/vue_springboot_package_publish/"
           data-tag="maven"
           data-author="沐雨云楼" >
            <span class="post-title" title="vue+springboot打包发布">vue+springboot打包发布</span>
            <span class="post-date" title="2020-10-06 14:22:29">2020/10/06</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/10/06/java-jpa-query/"
           data-tag="JPA"
           data-author="沐雨云楼" >
            <span class="post-title" title="JPA自定义sql">JPA自定义sql</span>
            <span class="post-date" title="2020-10-06 10:20:38">2020/10/06</span>
        </a>
        
        <a  class="微服务 spring "
           href="/blog/2020/10/03/spring-pageable/"
           data-tag="分页"
           data-author="沐雨云楼" >
            <span class="post-title" title="vue+springboot分页交互">vue+springboot分页交互</span>
            <span class="post-date" title="2020-10-03 11:08:21">2020/10/03</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/10/02/chrome-plugin/"
           data-tag="chrome"
           data-author="沐雨云楼" >
            <span class="post-title" title="chrome插件">chrome插件</span>
            <span class="post-date" title="2020-10-02 10:11:31">2020/10/02</span>
        </a>
        
        <a  class="windows "
           href="/blog/2020/10/01/windows-less-dll/"
           data-tag="dll"
           data-author="沐雨云楼" >
            <span class="post-title" title="windows缺少dll">windows缺少dll</span>
            <span class="post-date" title="2020-10-01 20:22:28">2020/10/01</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/09/13/java-base-bigdecimal/"
           data-tag="bigdecimal"
           data-author="沐雨云楼" >
            <span class="post-title" title="BigDecimal正确使用了吗?">BigDecimal正确使用了吗?</span>
            <span class="post-date" title="2020-09-13 10:28:54">2020/09/13</span>
        </a>
        
        <a  class="windows "
           href="/blog/2020/09/12/windows-dev-install/"
           data-tag="windows"
           data-author="沐雨云楼" >
            <span class="post-title" title="windows开发环境安装">windows开发环境安装</span>
            <span class="post-date" title="2020-09-12 21:39:01">2020/09/12</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/09/06/tool-notebook-joplin/"
           data-tag="joplin"
           data-author="沐雨云楼" >
            <span class="post-title" title="joplin笔记">joplin笔记</span>
            <span class="post-date" title="2020-09-06 20:50:55">2020/09/06</span>
        </a>
        
        <a  class="web vue "
           href="/blog/2020/09/05/vue-element-admin/"
           data-tag="web"
           data-author="沐雨云楼" >
            <span class="post-title" title="vue element admin开发">vue element admin开发</span>
            <span class="post-date" title="2020-09-05 11:01:38">2020/09/05</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/09/05/tool-notebook/"
           data-tag="notebook"
           data-author="沐雨云楼" >
            <span class="post-title" title="常见笔记软件">常见笔记软件</span>
            <span class="post-date" title="2020-09-05 10:54:34">2020/09/05</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/30/java-dao-shardingSphere/"
           data-tag="sharding-jdbc"
           data-author="沐雨云楼" >
            <span class="post-title" title="分库分表中间件-ShardingSphere">分库分表中间件-ShardingSphere</span>
            <span class="post-date" title="2020-08-30 21:52:45">2020/08/30</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/30/java-dao-mycat/"
           data-tag="mycat"
           data-author="沐雨云楼" >
            <span class="post-title" title="分库分表中间件-MyCat">分库分表中间件-MyCat</span>
            <span class="post-date" title="2020-08-30 15:01:59">2020/08/30</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/30/java-dao-sharding-db/"
           data-tag="分库分表"
           data-author="沐雨云楼" >
            <span class="post-title" title="分库分表中间件-开源产品">分库分表中间件-开源产品</span>
            <span class="post-date" title="2020-08-30 09:37:18">2020/08/30</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/29/java-jndi/"
           data-tag="jdni"
           data-author="沐雨云楼" >
            <span class="post-title" title="JNDI">JNDI</span>
            <span class="post-date" title="2020-08-29 17:12:03">2020/08/29</span>
        </a>
        
        <a  class="工具 git "
           href="/blog/2020/08/27/tool-git-setting/"
           data-tag="git"
           data-author="沐雨云楼" >
            <span class="post-title" title="git配置">git配置</span>
            <span class="post-date" title="2020-08-27 21:30:17">2020/08/27</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/08/23/java-powermock/"
           data-tag="powermock"
           data-author="沐雨云楼" >
            <span class="post-title" title="powermock测试框架">powermock测试框架</span>
            <span class="post-date" title="2020-08-23 12:45:17">2020/08/23</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/08/23/java-mockito/"
           data-tag="mock"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍mockito测试框架">👍mockito测试框架</span>
            <span class="post-date" title="2020-08-23 10:45:17">2020/08/23</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/08/22/java-test-ng/"
           data-tag="test"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍TestNG一篇足以">👍TestNG一篇足以</span>
            <span class="post-date" title="2020-08-22 18:37:28">2020/08/22</span>
        </a>
        
        <a  class="db mysql "
           href="/blog/2020/08/19/mysql-common-sql/"
           data-tag="mysql"
           data-author="沐雨云楼" >
            <span class="post-title" title="mysql常用sql">mysql常用sql</span>
            <span class="post-date" title="2020-08-19 21:30:00">2020/08/19</span>
        </a>
        
        <a  class="db mysql "
           href="/blog/2020/08/19/mysql-windows-zip-install/"
           data-tag="mysql"
           data-author="沐雨云楼" >
            <span class="post-title" title="mysql zip在windows上安装">mysql zip在windows上安装</span>
            <span class="post-date" title="2020-08-19 21:00:47">2020/08/19</span>
        </a>
        
        <a  class="工具 idea "
           href="/blog/2020/08/15/jetbrains-crack/"
           data-tag="工具,idea"
           data-author="沐雨云楼" >
            <span class="post-title" title="jetbrains全家桶破解">jetbrains全家桶破解</span>
            <span class="post-date" title="2020-08-15 19:22:33">2020/08/15</span>
        </a>
        
        <a  class="工具 git "
           href="/blog/2020/07/10/tool-git-error-name-too-long/"
           data-tag="git"
           data-author="沐雨云楼" >
            <span class="post-title" title="git文件名太长">git文件名太长</span>
            <span class="post-date" title="2020-07-10 12:03:02">2020/07/10</span>
        </a>
        
        <a  class="db mysql "
           href="/blog/2020/07/04/mysql-lock-unlock-table/"
           data-tag="lock"
           data-author="沐雨云楼" >
            <span class="post-title" title="mysql数据库锁查询和释放">mysql数据库锁查询和释放</span>
            <span class="post-date" title="2020-07-04 21:46:54">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-sort/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法8-排序">数据结构和算法8-排序</span>
            <span class="post-date" title="2020-07-04 18:49:12">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-search/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法7-搜索">数据结构和算法7-搜索</span>
            <span class="post-date" title="2020-07-04 17:48:19">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-graph/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法6-非线性-图">数据结构和算法6-非线性-图</span>
            <span class="post-date" title="2020-07-04 16:09:47">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-tree/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法5-非线性-树">数据结构和算法5-非线性-树</span>
            <span class="post-date" title="2020-07-04 15:09:47">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-linear-queue/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法4-线性-队列">数据结构和算法4-线性-队列</span>
            <span class="post-date" title="2020-07-04 14:10:22">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-linear-stack/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法3-线性-栈">数据结构和算法3-线性-栈</span>
            <span class="post-date" title="2020-07-04 13:00:17">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-linear-list/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法2-线性-链">数据结构和算法2-线性-链</span>
            <span class="post-date" title="2020-07-04 11:32:12">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-info/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法1-介绍">数据结构和算法1-介绍</span>
            <span class="post-date" title="2020-07-04 10:10:40">2020/07/04</span>
        </a>
        
        <a  class="大数据 spark "
           href="/blog/2020/06/30/spark-install-windows/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="spark开发环境搭建">spark开发环境搭建</span>
            <span class="post-date" title="2020-06-30 19:24:51">2020/06/30</span>
        </a>
        
        <a  class="大数据 hadoop "
           href="/blog/2020/06/30/hadoop-install-windows/"
           data-tag="hadoop"
           data-author="沐雨云楼" >
            <span class="post-title" title="hadoop开发环境搭建">hadoop开发环境搭建</span>
            <span class="post-date" title="2020-06-30 18:06:23">2020/06/30</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/06/30/java-install-windows/"
           data-tag="java"
           data-author="沐雨云楼" >
            <span class="post-title" title="jdk开发环境搭建">jdk开发环境搭建</span>
            <span class="post-date" title="2020-06-30 15:09:34">2020/06/30</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/06/30/ai-python-spark-env/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="python spark开发环境搭建">python spark开发环境搭建</span>
            <span class="post-date" title="2020-06-30 12:14:04">2020/06/30</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/06/29/ai-jupyter-notebook/"
           data-tag="标签"
           data-author="沐雨云楼" >
            <span class="post-title" title="jupyter notebook">jupyter notebook</span>
            <span class="post-date" title="2020-06-29 12:29:36">2020/06/29</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/06/26/ai-python-tools/"
           data-tag="tools"
           data-author="沐雨云楼" >
            <span class="post-title" title="python和ai常用工具">python和ai常用工具</span>
            <span class="post-date" title="2020-06-26 09:55:24">2020/06/26</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/06/25/python-tool-buildin-attr/"
           data-tag="attr"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍python内置属性(魔法方法)">👍python内置属性(魔法方法)</span>
            <span class="post-date" title="2020-06-25 11:01:33">2020/06/25</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/06/24/python-tool-buildin-func/"
           data-tag="func"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍python内置函数">👍python内置函数</span>
            <span class="post-date" title="2020-06-24 18:31:59">2020/06/24</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/06/24/python-tool-obj-dict/"
           data-tag="dict"
           data-author="沐雨云楼" >
            <span class="post-title" title="python对象与dict互转">python对象与dict互转</span>
            <span class="post-date" title="2020-06-24 18:15:03">2020/06/24</span>
        </a>
        
        <a  class="大数据 spark "
           href="/blog/2020/06/21/spark-version-3/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="spark3.0新特性">spark3.0新特性</span>
            <span class="post-date" title="2020-06-21 17:40:12">2020/06/21</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/06/21/java-base-domain/"
           data-tag="domain"
           data-author="沐雨云楼" >
            <span class="post-title" title="VO DTO DO PO你都了解吗?">VO DTO DO PO你都了解吗?</span>
            <span class="post-date" title="2020-06-21 09:20:03">2020/06/21</span>
        </a>
        
        <a  class="大数据 spark "
           href="/blog/2020/06/20/spark-data-skew/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="spark数据倾斜及解决方案">spark数据倾斜及解决方案</span>
            <span class="post-date" title="2020-06-20 21:41:12">2020/06/20</span>
        </a>
        
        <a  class="linux nginx "
           href="/blog/2020/06/20/nginx-fast/"
           data-tag="nginx"
           data-author="沐雨云楼" >
            <span class="post-title" title="nginx为何这么快?">nginx为何这么快?</span>
            <span class="post-date" title="2020-06-20 17:55:10">2020/06/20</span>
        </a>
        
        <a  class="架构 "
           href="/blog/2020/06/20/fw-mq-message-missing/"
           data-tag="mq"
           data-author="沐雨云楼" >
            <span class="post-title" title="MQ如何保证消息不丢失?">MQ如何保证消息不丢失?</span>
            <span class="post-date" title="2020-06-20 17:03:18">2020/06/20</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/06/20/java-base-serializable/"
           data-tag="序列化"
           data-author="沐雨云楼" >
            <span class="post-title" title="java序列化">java序列化</span>
            <span class="post-date" title="2020-06-20 16:29:04">2020/06/20</span>
        </a>
        
        <a  class="架构 "
           href="/blog/2020/06/20/fw-distributed-lock-redis-zk/"
           data-tag="lock,redis,zookeeper"
           data-author="沐雨云楼" >
            <span class="post-title" title="分布式锁用redis还是zk?">分布式锁用redis还是zk?</span>
            <span class="post-date" title="2020-06-20 12:09:55">2020/06/20</span>
        </a>
        
        <a  class="java tools "
           href="/blog/2020/06/19/java-tool-jackson/"
           data-tag="jackson"
           data-author="沐雨云楼" >
            <span class="post-title" title="工具类--jackson">工具类--jackson</span>
            <span class="post-date" title="2020-06-19 13:00:45">2020/06/19</span>
        </a>
        
        <a  class="java tools "
           href="/blog/2020/06/19/java-tool-bean-map/"
           data-tag="beanmap"
           data-author="沐雨云楼" >
            <span class="post-title" title="工具类--bean和map互转">工具类--bean和map互转</span>
            <span class="post-date" title="2020-06-19 12:30:14">2020/06/19</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/06/18/java-rest-assured-in-action/"
           data-tag="rest"
           data-author="沐雨云楼" >
            <span class="post-title" title="rest-assured实战">rest-assured实战</span>
            <span class="post-date" title="2020-06-18 17:51:56">2020/06/18</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/06/17/java_rest_assured_wiki_info/"
           data-tag="rest"
           data-author="沐雨云楼" >
            <span class="post-title" title="rest-assured wiki翻译">rest-assured wiki翻译</span>
            <span class="post-date" title="2020-06-17 20:39:11">2020/06/17</span>
        </a>
        
        <a  class="python tornado "
           href="/blog/2020/06/16/tornado-wtforms/"
           data-tag="wtforms"
           data-author="沐雨云楼" >
            <span class="post-title" title="wtforms表单验证">wtforms表单验证</span>
            <span class="post-date" title="2020-06-16 21:52:33">2020/06/16</span>
        </a>
        
        <a  class="python tornado "
           href="/blog/2020/06/16/tornado-sync-to-async/"
           data-tag="aysnc"
           data-author="沐雨云楼" >
            <span class="post-title" title="tornado同步转异步">tornado同步转异步</span>
            <span class="post-date" title="2020-06-16 21:50:25">2020/06/16</span>
        </a>
        
        <a  class="python tornado "
           href="/blog/2020/06/08/python_tornado_info/"
           data-tag="tornado"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍Tornado入门这一篇足以">👍Tornado入门这一篇足以</span>
            <span class="post-date" title="2020-06-08 20:31:32">2020/06/08</span>
        </a>
        
        <a  class="工具 maven "
           href="/blog/2020/06/07/tool-maven/"
           data-tag="tools,工具"
           data-author="沐雨云楼" >
            <span class="post-title" title="maven常用命令和配置">maven常用命令和配置</span>
            <span class="post-date" title="2020-06-07 16:30:11">2020/06/07</span>
        </a>
        
        <a  class="微服务 springboot "
           href="/blog/2020/06/07/spring-initialzr/"
           data-tag="tools,工具"
           data-author="沐雨云楼" >
            <span class="post-title" title="spring initialzr环境编译发布">spring initialzr环境编译发布</span>
            <span class="post-date" title="2020-06-07 15:06:00">2020/06/07</span>
        </a>
        
        <a  class="windows "
           href="/blog/2020/06/07/windows-cmd/"
           data-tag="tools,工具,命令"
           data-author="沐雨云楼" >
            <span class="post-title" title="windows常用命令和技巧">windows常用命令和技巧</span>
            <span class="post-date" title="2020-06-07 11:39:01">2020/06/07</span>
        </a>
        
        <a  class="工具 github "
           href="/blog/2020/06/07/tool-connect-github/"
           data-tag="github"
           data-author="沐雨云楼" >
            <span class="post-title" title="github无法访问解决办法">github无法访问解决办法</span>
            <span class="post-date" title="2020-06-07 10:08:38">2020/06/07</span>
        </a>
        
        <a  class="微服务 spring "
           href="/blog/2020/06/03/spring-transaction/"
           data-tag="transactional"
           data-author="沐雨云楼" >
            <span class="post-title" title="Transactional注解">Transactional注解</span>
            <span class="post-date" title="2020-06-03 22:09:42">2020/06/03</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/06/03/java-jpa-query-multi-param/"
           data-tag="JPA"
           data-author="沐雨云楼" >
            <span class="post-title" title="JPA多条件查询">JPA多条件查询</span>
            <span class="post-date" title="2020-06-03 21:38:04">2020/06/03</span>
        </a>
        
        <a  class="java tools "
           href="/blog/2020/06/02/java-tool-fastjson-bug/"
           data-tag="fastjson"
           data-author="沐雨云楼" >
            <span class="post-title" title="Fastjson远程代码高危漏洞">Fastjson远程代码高危漏洞</span>
            <span class="post-date" title="2020-06-02 22:38:28">2020/06/02</span>
        </a>
        
        <a  class="linux docker "
           href="/blog/2020/06/02/docker-introduction/"
           data-tag="docker"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍docker入门看这一篇就够了">👍docker入门看这一篇就够了</span>
            <span class="post-date" title="2020-06-02 22:22:30">2020/06/02</span>
        </a>
        
        <a  class="面试 "
           href="/blog/2020/06/02/interview-java-question/"
           data-tag="面试"
           data-author="沐雨云楼" >
            <span class="post-title" title="java常见面试题">java常见面试题</span>
            <span class="post-date" title="2020-06-02 22:15:48">2020/06/02</span>
        </a>
        
        <a  class="微服务 "
           href="/blog/2020/06/02/microservice-why/"
           data-tag="微服务"
           data-author="沐雨云楼" >
            <span class="post-title" title="牛逼公司一定要使用微服务？">牛逼公司一定要使用微服务？</span>
            <span class="post-date" title="2020-06-02 21:15:29">2020/06/02</span>
        </a>
        
        <a  class="面试 "
           href="/blog/2020/06/02/interview-company/"
           data-tag="面试"
           data-author="沐雨云楼" >
            <span class="post-title" title="IT互联网公司名单">IT互联网公司名单</span>
            <span class="post-date" title="2020-06-02 20:41:23">2020/06/02</span>
        </a>
        
        <a  class="java 并发 "
           href="/blog/2020/06/02/java-concurrent-aqs/"
           data-tag="java,并发"
           data-author="沐雨云楼" >
            <span class="post-title" title="java并发AQS">java并发AQS</span>
            <span class="post-date" title="2020-06-02 20:01:48">2020/06/02</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/05/30/ai-learn-catalog/"
           data-tag="ai"
           data-author="沐雨云楼" >
            <span class="post-title" title="AI学习目录">AI学习目录</span>
            <span class="post-date" title="2020-05-30 08:49:39">2020/05/30</span>
        </a>
        
        <a  class="工具 hexo "
           href="/blog/2020/05/29/hexo-theme-math/"
           data-tag="工具,hexo"
           data-author="沐雨云楼" >
            <span class="post-title" title="hexo主题支持MathJax">hexo主题支持MathJax</span>
            <span class="post-date" title="2020-05-29 09:36:46">2020/05/29</span>
        </a>
        
        <a  class="db redis "
           href="/blog/2020/05/28/redis-memory-eliminate/"
           data-tag="redis"
           data-author="沐雨云楼" >
            <span class="post-title" title="Redis的内存淘汰策略">Redis的内存淘汰策略</span>
            <span class="post-date" title="2020-05-28 21:37:04">2020/05/28</span>
        </a>
        
        <a  class="工具 markdowm "
           href="/blog/2020/05/28/markdown-math-express/"
           data-tag="工具,markdowm"
           data-author="沐雨云楼" >
            <span class="post-title" title="markdown数学公式">markdown数学公式</span>
            <span class="post-date" title="2020-05-28 08:02:03">2020/05/28</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/05/21/python_install/"
           data-tag="python"
           data-author="沐雨云楼" >
            <span class="post-title" title="python环境安装">python环境安装</span>
            <span class="post-date" title="2020-05-21 21:37:04">2020/05/21</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/05/21/python_base/"
           data-tag="python"
           data-author="沐雨云楼" >
            <span class="post-title" title="python基本语法">python基本语法</span>
            <span class="post-date" title="2020-05-21 00:00:00">2020/05/21</span>
        </a>
        
        <a  class="其他 "
           href="/blog/2020/05/20/todo-list/"
           data-tag="plan,计划"
           data-author="沐雨云楼" >
            <span class="post-title" title="计划">计划</span>
            <span class="post-date" title="2020-05-20 11:04:19">2020/05/20</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/05/20/blog-template/"
           data-tag="模板"
           data-author="沐雨云楼" >
            <span class="post-title" title="博客自定义模板">博客自定义模板</span>
            <span class="post-date" title="2020-05-20 05:20:00">2020/05/20</span>
        </a>
        
    </nav>
</div>

    </div>
    <div class="hide-list">
        <div class="semicircle" data-title="切换全屏 快捷键 s">
            <div class="brackets first"><</div>
            <div class="brackets">&gt;</div>
        </div>
    </div>
</aside>
<div class="post">
    <div class="pjax">
        <article id="post-java-test-ng" class="article article-type-post" itemscope itemprop="blogPost">
    
        <h1 class="article-title">👍TestNG一篇足以</h1>
    
    <div class="article-meta">
        
        
        <span class="author"><a>沐雨云楼</a></span>
        
        
        <span class="book">
            
                <a  data-rel="java">java</a>/
            
                <a  data-rel="test">test</a>
            
        </span>
        
        
        <span class="tag">
            
            <a class="color5">test</a>
            
        </span>
        
    </div>
    <div class="article-meta">
        
            发布时间 : <time class="date" title='最后更新: 2020-09-12 21:21:47'>2020-08-22 18:37</time>
        
    </div>
    <div class="article-meta">
        
        <span>字数:5k</span>
        
        
        <span id="busuanzi_container_page_pv">
            阅读 :<span id="busuanzi_value_page_pv">
                <span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </span>
        </span>
        
        
        <span class="top-comment" title="跳转至评论区">
            <a href="#comments">
                评论:<span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </a>
        </span>
        
    </div>
    
    <div class="toc-ref">
    
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-TestNG"><span class="toc-text">1.TestNG</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-是什么？"><span class="toc-text">1-1.是什么？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-插件"><span class="toc-text">1-2.插件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-TestNG的优点"><span class="toc-text">1-3.TestNG的优点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-4-层次结构"><span class="toc-text">1-4.层次结构</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-5-运行方式"><span class="toc-text">1-5.运行方式</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-简单示例"><span class="toc-text">2.简单示例</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-基本类"><span class="toc-text">2-1.基本类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-测试类演示"><span class="toc-text">2-2.测试类演示</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-1-最简单测试类"><span class="toc-text">2-2-1.最简单测试类</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-2-执行顺序"><span class="toc-text">2-2-2.执行顺序</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-3-忽略测试"><span class="toc-text">2-2-3.忽略测试</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-4-提供数据"><span class="toc-text">2-2-4.提供数据</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2-4-1-Parameters方式"><span class="toc-text">2-2-4-1.Parameters方式</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2-4-2-DataProvider方式"><span class="toc-text">2-2-4-2.DataProvider方式</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-5-依赖"><span class="toc-text">2-2-5.依赖</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-6-优先级"><span class="toc-text">2-2-6.优先级</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-7-异常"><span class="toc-text">2-2-7.异常</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-8-超时"><span class="toc-text">2-2-8.超时</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-suite套件测试"><span class="toc-text">3.suite套件测试</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1-配置文件"><span class="toc-text">3-1.配置文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2-测试类"><span class="toc-text">3-2.测试类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-3-结果"><span class="toc-text">3-3.结果</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-分组"><span class="toc-text">4.分组</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4-1-方法分组"><span class="toc-text">4-1.方法分组</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-2-类分组"><span class="toc-text">4-2.类分组</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#4-2-1-类"><span class="toc-text">4-2-1.类</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-2-2-配置文件"><span class="toc-text">4-2-2.配置文件</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-多线程"><span class="toc-text">5.多线程</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#5-1-测试类"><span class="toc-text">5-1.测试类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-2-配置"><span class="toc-text">5-2.配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#5-2-1-methods"><span class="toc-text">5-2-1.methods</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-2-2-tests"><span class="toc-text">5-2-2.tests</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-2-3-classes"><span class="toc-text">5-2-3.classes</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-3-注解多线程"><span class="toc-text">5-3.注解多线程</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-报告"><span class="toc-text">6.报告</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#6-1-ExtentReport报告"><span class="toc-text">6-1.ExtentReport报告</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-2-Allure报告"><span class="toc-text">6-2.Allure报告</span></a></li></ol></li></ol>
    
<style>
    .left-col .switch-btn,
    .left-col .switch-area {
        display: none;
    }
    .toc-level-4 i,
    .toc-level-4 ol {
        display: none !important;
    }
</style>
</div>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>本篇只能算入门，介绍一些常用的功能。</p>
<h2 id="1-TestNG"><a href="#1-TestNG" class="headerlink" title="1.TestNG"></a>1.TestNG</h2><h3 id="1-1-是什么？"><a href="#1-1-是什么？" class="headerlink" title="1-1.是什么？"></a>1-1.是什么？</h3><p>TestNG，即Testing, Next Generation，下一代测试技术，是一套根据JUnit和NUnit思想而构建的利用注释来强化测试功能的一个测试框架，即可以用来做单元测试，也可以用来做集成测试。</p>
<ul>
<li><a href="https://github.com/cbeust/testng/" target="_blank" rel="noopener">github地址</a></li>
<li><a href="https://testng.org/doc/documentation-main.html" target="_blank" rel="noopener">官网doc</a></li>
</ul>
<h3 id="1-2-插件"><a href="#1-2-插件" class="headerlink" title="1-2.插件"></a>1-2.插件</h3><p><strong>idea</strong></p>
<p>idea去plugin里搜索<code>TestNG</code>，然后点击install，重启idea即可</p>
<img src="/blog/images/java/testng/testng-idea-plugin.png" width="650px">


<p><strong>Eclipse</strong></p>
<ul>
<li><a href="http://testng.org/doc/download.html" target="_blank" rel="noopener">TestNG Eclipse插件下载地址</a></li>
</ul>
<p>放在eclipse的plugins文件夹下，然后启动eclipse，点击Help -&gt; software update -&gt; Installed Software, 查找到TestNG Eclipse插件，点击Install（安装），安装完成后，重启eclipse。</p>
<h3 id="1-3-TestNG的优点"><a href="#1-3-TestNG的优点" class="headerlink" title="1-3.TestNG的优点"></a>1-3.TestNG的优点</h3><ul>
<li>漂亮的HTML格式测试报告</li>
<li>支持并发测试</li>
<li>参数化测试更简单</li>
<li>支持输出日志</li>
<li>支持更多功能的注解</li>
<li>更适合集成测试</li>
</ul>
<h3 id="1-4-层次结构"><a href="#1-4-层次结构" class="headerlink" title="1-4.层次结构"></a>1-4.层次结构</h3><ul>
<li>一个suite(套件) 由一个或多个测试组成。</li>
<li>一个test(测试) 由一个或多个类组成</li>
<li>一个class(类) 由一个或多个方法组成。</li>
</ul>
<img src="/blog/images/java/testng/testng-level.png" width="650px">

<ul>
<li><code>@BeforeSuite/@AfterSuite</code> 在某个测试套件开始之前/在某个套件所有测试方法执行之后</li>
<li><code>@BeforeTest/@AfterTest</code> 在某个测试开始之前/在某个测试所有测试方法执行之后</li>
<li><code>@BeforeClass/@AfterClass</code> 在某个测试类开始之前/在某个类的所有测试方法执行之后</li>
<li><code>@BeforeMethod/@AfterMethod</code> 在某个测试方法之前/在某个测试方法执行之后</li>
<li><code>@BeforeGroup/@AfterGroup</code> 在某个组的所有测试方法之前/在某个组的所有测试方法执行之后</li>
</ul>
<h3 id="1-5-运行方式"><a href="#1-5-运行方式" class="headerlink" title="1-5.运行方式"></a>1-5.运行方式</h3><ul>
<li>With a testng.xml file  (直接run as test suite)</li>
<li>With ant  (使用ant)</li>
<li>From the command line  (从命令行)</li>
<li>IDE  (直接在IDE中执行)</li>
</ul>
<h2 id="2-简单示例"><a href="#2-简单示例" class="headerlink" title="2.简单示例"></a>2.简单示例</h2><p><a href="https://gitee.com/iworkh/iworkh-test-testng" target="_blank" rel="noopener">本篇的源码地址</a></p>
<blockquote>
<p>code目录下，<code>testng-demo</code>子项目中。</p>
</blockquote>
<h3 id="2-1-基本类"><a href="#2-1-基本类" class="headerlink" title="2-1.基本类"></a>2-1.基本类</h3><p>先添加jar依赖</p>
<p><strong>pom依赖</strong></p>
<pre><code class="xml">&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.testng&lt;/groupId&gt;
        &lt;artifactId&gt;testng&lt;/artifactId&gt;
        &lt;version&gt;6.14.3&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;</code></pre>
<div class="admonition attention">
    <p class="fa admonition-title">注意：</p>
    <div>
        <li>这注意版版本不要用太新了。目前2020年8月，最新的版本是7.3.0，但是这选择的版本是 6.14.3。</li>
        <li>使用7.1.0的使用@BeforeGroup和@AfterGroup无效，换低版本就好了。</li>
        <li>使用7.3.0的使用idea在run测试类时候报错了TestNG by default disables loading DTD from unsecured Urls，换低版本就好了。</li>
        <li>idea的TestNG插件版本和TestNG的版本间版本间有问题。所以选择版本时候，要注意不要使用太新的。自己测试下。</li>
    </div>
</div>


<p><strong>实体类</strong></p>
<pre><code class="java">public class Student {
    private int id;
    private String name;
    private boolean sex;

    ...省略setter、gettter、toString、构造方法...
}</code></pre>
<p><strong>dao</strong></p>
<pre><code class="java">public class StudentDao {

    public void add(Student student){
        System.out.println(&quot;StudentDao ## add&quot;);
    }

    public List&lt;Student&gt; list(){
        System.out.println(&quot;StudentDao ## list&quot;);
        List&lt;Student&gt; students = new ArrayList&lt;&gt;();
        students.add(new Student(1, &quot;沐雨云楼&quot;, true));
        students.add(new Student(2, &quot;张三&quot;, false));
        return students;
    }

    public void delete(int id){
        System.out.println(&quot;StudentDao ## delete&quot;);
    }
}</code></pre>
<p><strong>service</strong></p>
<pre><code class="java">public class StudentService {

    public StudentDao studentDao;

    public void add(Student student){
        System.out.println(&quot;StudentService ## add&quot;);
        studentDao.add(student);
    }

    public List&lt;Student&gt; list(){
        System.out.println(&quot;StudentService ## list&quot;);
        return studentDao.list();
    }

    public void delete(int id){
        System.out.println(&quot;StudentService ## delete&quot;);
        studentDao.delete(id);
    }
}</code></pre>
<h3 id="2-2-测试类演示"><a href="#2-2-测试类演示" class="headerlink" title="2-2.测试类演示"></a>2-2.测试类演示</h3><h4 id="2-2-1-最简单测试类"><a href="#2-2-1-最简单测试类" class="headerlink" title="2-2-1.最简单测试类"></a>2-2-1.最简单测试类</h4><p>我是用idea来开发的，讲下如何快速生成测试类</p>
<blockquote>
<p>快捷键: <code>alter</code>+<code>insert</code>生成测试类</p>
</blockquote>
<img src="/blog/images/java/testng/testng-idea-generate.png" width="650px">


<p><strong>简单测试类</strong></p>
<pre><code class="java">public class StudentDaoTest {
    @Test
    public void testAdd() {
        System.out.println(&quot;testAdd&quot;);
    }

    @Test
    public void testList() {
        System.out.println(&quot;testList&quot;);
    }

    @Test
    public void testDelete() {
        System.out.println(&quot;testDelete&quot;);
    }
}</code></pre>
<blockquote>
<p>类和方法上都可以run来测试</p>
</blockquote>
<h4 id="2-2-2-执行顺序"><a href="#2-2-2-执行顺序" class="headerlink" title="2-2-2.执行顺序"></a>2-2-2.执行顺序</h4><table>
<thead>
<tr>
<th>注解</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td><code>@BeforeSuite</code></td>
<td>表示会在当前测试集合中的任意一个测试用例开始运行前执行</td>
</tr>
<tr>
<td><code>@AfterSuite</code></td>
<td>表示会在当前测试集合中的所有测试程序运行结束之后执行</td>
</tr>
<tr>
<td><code>@BeforeTest</code></td>
<td>表示会在Test中的任意一个测试用例开始运行前执行</td>
</tr>
<tr>
<td><code>@AfterTest</code></td>
<td>表示会在Test中的所有测试用例运行结束后执行</td>
</tr>
<tr>
<td><code>@BeforeGroups</code></td>
<td>分组测试用例的任一测试用例开始运行前执行</td>
</tr>
<tr>
<td><code>@AfterGroups</code></td>
<td>分组测试用例的所有测试用例运行结束后执行</td>
</tr>
<tr>
<td><code>@BeforeClass</code></td>
<td>在当前测试类的任意一个测试用例开始运行前执行</td>
</tr>
<tr>
<td><code>@AfterClass</code></td>
<td>在当前测试类的所有测试用例运行结束后执行</td>
</tr>
<tr>
<td><code>@BeforeMethod</code></td>
<td>在每个测试方法开始运行前执行</td>
</tr>
<tr>
<td><code>@AfterMethod</code></td>
<td>在每个测试方法运行结束后执行</td>
</tr>
<tr>
<td><code>@Test</code></td>
<td>被认为是一个测试方法，既一个测试用例</td>
</tr>
</tbody></table>
<p>执行顺序: <code>@BeforeSuite &gt; @BeforeTest &gt; @BeforeMethod &gt; @Test &gt; @AfterMethod &gt; @AfterTest &gt; @AfterSuite</code></p>
<img src="/blog/images/java/testng/testng-before-after-order.png" width="650px">


<p>使用最多就是<code>@BeforeClass</code>和<code>@AfterClass</code></p>
<pre><code class="java">public class StudentDaoTest {

    private StudentDao studentDao;

    @BeforeClass
    public void beforeClass() {
        System.out.println(&quot;beforeClass###&quot;);
        studentDao = new StudentDao();
    }

    @AfterClass
    public void afterClass() {
        System.out.println(&quot;afterClass###&quot;);
    }

    @BeforeMethod
    public void beforeMethod() {
        System.out.println(&quot;beforeMethod...&quot;);
    }

    @AfterMethod
    public void afterMethod() {
        System.out.println(&quot;afterMethod...&quot;);
    }

    @Test
    public void testAdd() {
        System.out.println(&quot;testAdd&quot;);
        studentDao.add(new Student(3,&quot;超级飞侠&quot;,true));
    }

    @Test
    public void testList() {
        System.out.println(&quot;testList&quot;);
    }

    @Test
    public void testDelete() {
        System.out.println(&quot;testDelete&quot;);
    }
}</code></pre>
<p><strong>结果：</strong></p>
<pre><code class="result">beforeClass###

beforeMethod...
testAdd
StudentDao ## add
afterMethod...

beforeMethod...
testDelete
afterMethod...

beforeMethod...
testList
afterMethod...

afterClass###</code></pre>
<h4 id="2-2-3-忽略测试"><a href="#2-2-3-忽略测试" class="headerlink" title="2-2-3.忽略测试"></a>2-2-3.忽略测试</h4><ul>
<li>忽略整个包 <code>@Ignore</code></li>
<li>忽略整个测试类 <code>@Ignore</code></li>
<li>忽略某个方法 <code>@Test(enabled = false)</code></li>
</ul>
<p><strong>忽略整个包</strong></p>
<pre><code class="java">@Ignore
package com.iworkh.testng;

import org.testng.annotations.Ignore;
</code></pre>
<p><strong>忽略整个测试类</strong></p>
<pre><code class="java">@Ignore
public class StudentDaoIgnoreTest {

    @Test
    public void testAdd() {
        System.out.println(&quot;testAdd&quot;);
    }

    public void testList() {
        System.out.println(&quot;testList&quot;);
    }

    @Test
    public void testDelete() {
        System.out.println(&quot;testDelete&quot;);
    }
}</code></pre>
<blockquote>
<p>在类上加<code>@Ignore</code>注解</p>
</blockquote>
<p><strong>忽略某个方法</strong></p>
<pre><code class="java">public class StudentDaoIgnoreTest {

    @Test
    public void testAdd() {
        System.out.println(&quot;testAdd&quot;);
    }

    @Test(enabled = false)
    public void testList() {
        System.out.println(&quot;testList&quot;);
    }

    @Test
    public void testDelete() {
        System.out.println(&quot;testDelete&quot;);
    }
}</code></pre>
<blockquote>
<p>在不需要测试的方法上的@Test的属性里设置<code>@Test(enabled = false)</code></p>
</blockquote>
<h4 id="2-2-4-提供数据"><a href="#2-2-4-提供数据" class="headerlink" title="2-2-4.提供数据"></a>2-2-4.提供数据</h4><p>共两种方式</p>
<ul>
<li>通过xml和<code>@Parameters</code></li>
<li>通过<code>@DataProvider</code>注解</li>
</ul>
<h5 id="2-2-4-1-Parameters方式"><a href="#2-2-4-1-Parameters方式" class="headerlink" title="2-2-4-1.Parameters方式"></a>2-2-4-1.Parameters方式</h5><p><strong>测试类</strong></p>
<pre><code class="java">public class StudentDaoParameterTest {

    @Test
    @Parameters({&quot;id&quot;, &quot;name&quot;, &quot;sex&quot;})
    public void testAdd(int id, String name, boolean sex) {
        System.out.println(&quot;testAdd&quot;);
        System.out.println(new Student(id, name, sex));
    }
}</code></pre>
<p><strong>配置文件：testng-parameters.xml</strong></p>
<pre><code class="xml">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot; &gt;

&lt;suite name=&quot;testSuite&quot; verbose=&quot;1&quot; &gt;

    &lt;test name=&quot;testParams&quot;&gt;
        &lt;parameter name=&quot;id&quot; value=&quot;10&quot;/&gt;
        &lt;parameter name=&quot;name&quot; value=&quot;豆豆&quot;/&gt;
        &lt;parameter name=&quot;sex&quot; value=&quot;false&quot;/&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.dao.StudentDaoParameterTest&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;
&lt;/suite&gt;</code></pre>
<blockquote>
<p>通过run配置文件，查看结果</p>
</blockquote>
<h5 id="2-2-4-2-DataProvider方式"><a href="#2-2-4-2-DataProvider方式" class="headerlink" title="2-2-4-2.DataProvider方式"></a>2-2-4-2.DataProvider方式</h5><p>为测试方法提供数据，使用<code>@DataProvider</code>注解。<code>@DataProvider</code>也有两种形式： </p>
<ul>
<li>第一种：把在测试代码和测试数据放在同一个类中； </li>
<li>第二种：把所有的数据提供都单独写在一个类里面，当测试数据比较多时，这种方法利于维护。 </li>
</ul>
<p><strong>测试类和测试数据在同一类</strong></p>
<pre><code class="java">public class StudentDaoDataProviderTest {

    @DataProvider(name = &quot;insertStu&quot;)
    public Object[] providerData() {
        Student student = new Student(5, &quot;王五&quot;, true);
        return new Object[]{student};
    }

    @Test(dataProvider = &quot;insertStu&quot;)
    // 方法参数要和dataProvider传来的参数一致
    public void testAdd(Student student) {
        System.out.println(&quot;testAdd&quot;);
        System.out.println(student);
    }
}</code></pre>
<p>两个地方需要注意：</p>
<ul>
<li>数据提供方法：使用<code>@DataProvider</code>在一个方法上，并定义名称；<code>@DataProvider</code>注解的方法返回值必须是<code>Object[]</code>或者<code>Object[][]</code>类型</li>
<li>数据使用方法：<code>@Test</code>的属性<code>dataProvider</code>名称要跟<code>@DataProvider</code>的name一致；方法参数要和dataProvider传来的参数一致</li>
</ul>
<p><strong>测试类和测试数据分开</strong></p>
<p>数据类</p>
<pre><code class="java">public class StudentDaoDataProvider {

    @DataProvider(name = &quot;listStus&quot;)
    public Object[][] providerData() {
        return new Object[][]{{1, &quot;沐雨云楼&quot;, true}, {2, &quot;小爱&quot;, false}, {3, &quot;亚瑟&quot;, true},};
    }
}</code></pre>
<p>测试类</p>
<pre><code class="java">public class StudentDaoDataProviderTest {
    @Test(dataProvider = &quot;listStus&quot;, dataProviderClass = StudentDaoDataProvider.class)
    // 参数要和dataProvider传来的参数一致
    public void testList(int id, String name, boolean sex) {
        System.out.println(&quot;testList&quot;);
        System.out.println(String.format(&quot;id: %d, 姓名: %s, 性别: %b&quot;, id, name, sex));
    }

}</code></pre>
<blockquote>
<p>这<code>@Test</code>属性dataProviderClass指定的数据提供类；dataProvider指定数据提供的方法上<code>@DataProvider</code>的name值</p>
</blockquote>
<h4 id="2-2-5-依赖"><a href="#2-2-5-依赖" class="headerlink" title="2-2-5.依赖"></a>2-2-5.依赖</h4><p>同一类中，多个方法的执行顺序,默认是按着字母顺序进行执行的。</p>
<p>如果有依赖关系的话，可以通过两种方式</p>
<ul>
<li>依赖方法 <code>dependsOnMethods</code>, 值是方法名，不支持正则</li>
<li>依赖组 <code>dependsOnGroups</code>，值是组名，支持正则</li>
</ul>
<blockquote>
<p>这简单说下group组的概念，即将可以将多个测试方法，分为一组。这样就可以方便管理。这样就可以使用<code>@BeforeGroup</code>,<code>@AfterGroup</code>,<code>@dependsOnGroups</code></p>
</blockquote>
<pre><code class="java">public class StudentDaoDependsTest {

    @Test
    public void testParent() {
        System.out.println(&quot;testParent&quot;);
    }

    @Test
    public void parentFirst() {
        System.out.println(&quot;parentFirst&quot;);
    }

    @Test
    public void parentSecond() {
        System.out.println(&quot;parentSecond&quot;);
    }

    @Test(dependsOnMethods = {&quot;testParent&quot;, &quot;parentFirst&quot;, &quot;parentSecond&quot;})
    // 依赖方法，值是方法名，不支持正则表达式
    public void testChild() {
        System.out.println(&quot;testChild&quot;);
    }

    @Test(groups = {&quot;env_1&quot;})
    public void firstEnv() {
        System.out.println(&quot;env_1&quot;);
    }

    @Test(groups = {&quot;env_2&quot;})
    public void secondEnv() {
        System.out.println(&quot;env_2&quot;);
    }

    @Test(dependsOnGroups = {&quot;env.*&quot;})
    // 依赖groups，值是group名，支持正则匹配
    public void biz() {
        System.out.println(&quot;startBiz&quot;);
    }
}</code></pre>
<h4 id="2-2-6-优先级"><a href="#2-2-6-优先级" class="headerlink" title="2-2-6.优先级"></a>2-2-6.优先级</h4><p>同一类中，多个方法的执行顺序,默认是按着字母顺序进行执行的。</p>
<p>还可以通过<code>@Test</code>的<code>priority</code>来指定数字,默认值是0。(按照数字大小顺序优先执行，优先执行1，然后是2…)</p>
<pre><code class="java">public class StudentDaoPriorityTest {

    @Test(priority = 1)
    public void one() {
        System.out.println(&quot;1&quot;);
    }

    @Test(priority = 2)
    public void two() {
        System.out.println(&quot;2&quot;);
    }

    @Test(priority = 100)
    public void last() {
        System.out.println(&quot;100&quot;);
    }
}
</code></pre>
<h4 id="2-2-7-异常"><a href="#2-2-7-异常" class="headerlink" title="2-2-7.异常"></a>2-2-7.异常</h4><ul>
<li>expectedExceptions: 匹配异常的类型</li>
<li>expectedExceptionsMessageRegExp: 匹配异常的message</li>
</ul>
<pre><code class="java">public class StudentDaoExceptionTest {

    @Test(expectedExceptions = ArithmeticException.class,
          expectedExceptionsMessageRegExp = &quot;.*zero.*&quot;)
    public void testDelete() {
        System.out.println(&quot;testDelete&quot;);
        System.out.println(1/0);
    }

    @Test(expectedExceptions = RuntimeException.class,
          expectedExceptionsMessageRegExp = &quot;增加数据异常&quot;)
    public void testAdd() {
        System.out.println(&quot;testAdd&quot;);
        throw new RuntimeException(&quot;增加数据异常&quot;);
    }
}</code></pre>
<h4 id="2-2-8-超时"><a href="#2-2-8-超时" class="headerlink" title="2-2-8.超时"></a>2-2-8.超时</h4><pre><code class="java">public class StudentDaoTimeOutTest {

    @Test(timeOut = 2000)
    public void timeOut() {
        try {
            // 未超时
            TimeUnit.SECONDS.sleep(1);
            // 超时
            // TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
<h2 id="3-suite套件测试"><a href="#3-suite套件测试" class="headerlink" title="3.suite套件测试"></a>3.suite套件测试</h2><img src="/blog/images/java/testng/testng-before-after-order.png" width="650px">


<h3 id="3-1-配置文件"><a href="#3-1-配置文件" class="headerlink" title="3-1.配置文件"></a>3-1.配置文件</h3><img src="/blog/images/java/testng/testng-level.png" width="650px">

<ul>
<li>一个suite(套件) 由一个或多个测试组成。</li>
<li>一个test(测试) 由一个或多个类组成</li>
<li>一个class(类) 由一个或多个方法组成。</li>
</ul>
<pre><code class="java">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot; &gt;

&lt;suite name=&quot;testSuite&quot; verbose=&quot;1&quot; &gt;
    &lt;test name=&quot;login&quot; &gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.suite.SuiteConfig&quot; /&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.suite.LoginTest&quot; /&gt;
        &lt;/classes&gt;
    &lt;/test&gt;

    &lt;test name=&quot;pay&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.suite.SuiteConfig&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.suite.PayTest&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;
&lt;/suite&gt;</code></pre>
<h3 id="3-2-测试类"><a href="#3-2-测试类" class="headerlink" title="3-2.测试类"></a>3-2.测试类</h3><p><strong>SuiteConfig</strong></p>
<pre><code class="java">public class SuiteConfig {

    @BeforeSuite
    public void beforeSuite(){
        System.out.println(&quot;SuiteConfig beforeSuite ###&quot;);
    }

    @AfterSuite
    public void afterSuite(){
        System.out.println(&quot;SuiteConfig afterSuite ###&quot;);
    }

    @BeforeTest
    public void beforeTest(){
        System.out.println(&quot;SuiteConfig beforeTest @@@&quot;);
    }

    @AfterTest
    public void afterTest(){
        System.out.println(&quot;SuiteConfig afterTest @@@&quot;);
    }
}</code></pre>
<p><strong>LoginTest</strong> </p>
<pre><code class="java">public class LoginTest {

    @BeforeClass
    public void beforeClass(){
        System.out.println(&quot;LoginTest beforeClass ...&quot;);
    }

    @AfterClass
    public void afterClass(){
        System.out.println(&quot;LoginTest afterClass ...&quot;);
    }

    @BeforeMethod
    public void beforeMethod(){
        System.out.println(&quot;LoginTest beforeMethod ...&quot;);
    }

    @AfterMethod
    public void afterMethod(){
        System.out.println(&quot;LoginTest afterMethod ...&quot;);
    }

    @Test
    public void testLogin() {
        System.out.println(&quot;LoginTest login&quot;);
    }

    @Test
    public void testLogOut() {
        System.out.println(&quot;LoginTest logout&quot;);
    }

}</code></pre>
<p><strong>PayTest</strong></p>
<pre><code class="java">public class PayTest {

    @Test
    public void testPay() {
        System.out.println(&quot;PayTest pay&quot;);
    }
}</code></pre>
<h3 id="3-3-结果"><a href="#3-3-结果" class="headerlink" title="3-3.结果"></a>3-3.结果</h3><p>如果run?</p>
<blockquote>
<p>这只讲idea的，其他方式自己官网找下</p>
</blockquote>
<img src="/blog/images/java/testng/testng-idea-run-xml.png" width="650px">

<p><strong>结果</strong></p>
<pre><code class="result">SuiteConfig beforeSuite ###
SuiteConfig beforeTest @@@

LoginTest beforeClass ...

LoginTest beforeMethod ...
LoginTest logout
LoginTest afterMethod ...

LoginTest beforeMethod ...
LoginTest login
LoginTest afterMethod ...

LoginTest afterClass ...

SuiteConfig afterTest @@@


SuiteConfig beforeTest @@@
PayTest pay
SuiteConfig afterTest @@@

SuiteConfig afterSuite ###</code></pre>
<blockquote>
<p>从上面结果可以看出，<code>@BeforeSuite</code>和<code>@AfterSuite</code>在一个suite配置中，只运行一次。</p>
</blockquote>
<h2 id="4-分组"><a href="#4-分组" class="headerlink" title="4.分组"></a>4.分组</h2><p>testng的组，可以对方法和类进行分组</p>
<h3 id="4-1-方法分组"><a href="#4-1-方法分组" class="headerlink" title="4-1.方法分组"></a>4-1.方法分组</h3><p>方法上分组比较简单，直接看代码</p>
<pre><code class="java">public class GroupOnMethodTest {

    @BeforeGroups(&quot;gpOne&quot;)
    public void beforeGroupOne(){
        System.out.println(&quot;beforeGroup_one&quot;);
    }

    @AfterGroups(&quot;gpOne&quot;)
    public void afterGroupOne(){
        System.out.println(&quot;afterGroup_one&quot;);
    }

    @Test(groups = &quot;gpOne&quot;)
    public void test1(){
        System.out.println(&quot;gp_one -- test1&quot;);
    }

    @Test(groups = &quot;gpOne&quot;)
    public void test2(){
        System.out.println(&quot;gp_one -- test2&quot;);
    }

    @Test(groups = &quot;gpTwo&quot;)
    public void test3(){
        System.out.println(&quot;gp_two -- test3&quot;);
    }
}</code></pre>
<h3 id="4-2-类分组"><a href="#4-2-类分组" class="headerlink" title="4-2.类分组"></a>4-2.类分组</h3><p>说明：<code>@Test</code>不一定非要写在方法上，如果写在类上，那么这个类中的public方法都会是测试方法。</p>
<p>类上分组测试，要使用到xml配置来run</p>
<h4 id="4-2-1-类"><a href="#4-2-1-类" class="headerlink" title="4-2-1.类"></a>4-2-1.类</h4><p>三个类共分为两组，然后来指定组来run</p>
<p><strong>GroupOnClassOne</strong></p>
<pre><code class="java">@Test(groups = &quot;goc_loginout&quot;)
public class GroupOnClassOne {

    public void testLogin(){
        System.out.println(&quot;GroupOnClassOne testLogin ...&quot;);
    }
}</code></pre>
<p><strong>GroupOnClassTwo</strong></p>
<pre><code class="java">@Test(groups = &quot;goc_loginout&quot;)
public class GroupOnClassTwo {

    public void testLogout(){
        System.out.println(&quot;GroupOnClassTwo testLogout ...&quot;);
    }
}</code></pre>
<p><strong>GroupOnClassThree</strong></p>
<pre><code class="java">@Test(groups = &quot;goc_pay&quot;)
public class GroupOnClassThree {

    public void testPay(){
        System.out.println(&quot;GroupOnClassThree testPay ...&quot;);
    }
}</code></pre>
<h4 id="4-2-2-配置文件"><a href="#4-2-2-配置文件" class="headerlink" title="4-2-2.配置文件"></a>4-2-2.配置文件</h4><pre><code class="xml">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot; &gt;

&lt;suite name=&quot;testSuite&quot; verbose=&quot;1&quot; &gt;

    &lt;test name=&quot;runAll&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.group.GroupOnClassOne&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.group.GroupOnClassTwo&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.group.GroupOnClassThree&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;

    &lt;test name=&quot;runGroupLoginout&quot;&gt;
        &lt;groups&gt;
            &lt;run&gt;
                &lt;include name=&quot;goc_loginout&quot;/&gt;
            &lt;/run&gt;
        &lt;/groups&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.group.GroupOnClassOne&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.group.GroupOnClassTwo&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.group.GroupOnClassThree&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;
&lt;/suite&gt;</code></pre>
<blockquote>
<p>使用<code>groups</code>、<code>run</code>、<code>include</code>几个标签来指定run的类上的组名</p>
</blockquote>
<h2 id="5-多线程"><a href="#5-多线程" class="headerlink" title="5.多线程"></a>5.多线程</h2><p>测试的级别由上至下可以分为<code>suite -&gt; test -&gt; class -&gt; method</code>，箭头的左边元素跟右边元素的关系是一对多的包含关系。</p>
<p><code>parallel</code>参数几个值：</p>
<ul>
<li>methods:  所有方法都在不同的线程中run<blockquote>
<p>一个线程负责一个<code>@Test</code>标签的程序，多个并行时，每个class，method之间的线程ID都不一样</p>
</blockquote>
</li>
<li>tests: 同一个<code>&lt;test&gt;</code>中类里的所有方法在一个线程中run<blockquote>
<p>一个线程负责一个TestNG.xml中的一个<code>&lt;Test&gt;</code>标签，多个并行时，每个<code>&lt;Test&gt;</code>所包含的class，method之间的线程ID是一致的，但是 每个<code>&lt;Test&gt;</code>之间的线程ID是不一致的</p>
</blockquote>
</li>
<li>classes:  同一个<code>&lt;class&gt;</code>中所有方法在一个线程中run<blockquote>
<p>一个线程负责一个class里面所有的带有<code>@Test</code>标签的method。多个并行时，每个class之间的线程id不一样，但是同一个class里的<code>@Test</code>的method线程id是一样的</p>
</blockquote>
</li>
<li>none: 不起多线程</li>
</ul>
<h3 id="5-1-测试类"><a href="#5-1-测试类" class="headerlink" title="5-1.测试类"></a>5-1.测试类</h3><p><strong>测试类一：ThreadByXmlTestFirst</strong></p>
<pre><code>public class ThreadByXmlTestFirst {

    @Test
    public void testOne() {
        System.out.println(&quot;ThreadByXmlTestFirst ## 方法一：&quot; + Thread.currentThread().getId());
    }

    @Test
    public void testTwo() {
        System.out.println(&quot;ThreadByXmlTestFirst ## 方法二：&quot; + Thread.currentThread().getId());
    }
}</code></pre><p><strong>测试类二：ThreadByXmlTestSecond</strong></p>
<pre><code class="java">public class ThreadByXmlTestSecond {

    @Test
    public void testOne() {
        System.out.println(&quot;ThreadByXmlTestSecond ## 方法一：&quot; + Thread.currentThread().getId());
    }

    @Test
    public void testTwo() {
        System.out.println(&quot;ThreadByXmlTestSecond ## 方法二：&quot; + Thread.currentThread().getId());
    }
}</code></pre>
<p><strong>测试类三：ThreadByXmlTestThree</strong></p>
<pre><code class="java">public class ThreadByXmlTestThree {

    @Test
    public void testOne() {
        System.out.println(&quot;ThreadByXmlTestThree ## 方法一：&quot; + Thread.currentThread().getId());
    }

    @Test
    public void testTwo() {
        System.out.println(&quot;ThreadByXmlTestThree ## 方法二：&quot; + Thread.currentThread().getId());
    }
}</code></pre>
<h3 id="5-2-配置"><a href="#5-2-配置" class="headerlink" title="5-2.配置"></a>5-2.配置</h3><h4 id="5-2-1-methods"><a href="#5-2-1-methods" class="headerlink" title="5-2-1.methods"></a>5-2-1.methods</h4><p>每个测试方法都用一个线程来run。</p>
<p><strong>配置</strong></p>
<pre><code class="xml">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot; &gt;

&lt;suite name=&quot;testSuite&quot; verbose=&quot;1&quot; parallel=&quot;methods&quot; thread-count=&quot;5&quot;&gt;

    &lt;test name=&quot;threadXml_A&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestFirst&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestSecond&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;

    &lt;test name=&quot;threadXml_B&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestFirst&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;
&lt;/suite&gt;</code></pre>
<p><strong>结果</strong></p>
<pre><code class="result">ThreadByXmlTestFirst ## 方法二：14
ThreadByXmlTestFirst ## 方法一：13

ThreadByXmlTestSecond ## 方法二：16
ThreadByXmlTestSecond ## 方法一：15</code></pre>
<h4 id="5-2-2-tests"><a href="#5-2-2-tests" class="headerlink" title="5-2-2.tests"></a>5-2-2.tests</h4><p>同一test下的类里所有方法都用一个线程来run。</p>
<p><strong>配置</strong></p>
<pre><code class="xml">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot; &gt;

&lt;suite name=&quot;testSuite&quot; verbose=&quot;1&quot; parallel=&quot;tests&quot; thread-count=&quot;5&quot;&gt;

    &lt;test name=&quot;threadXml_A&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestFirst&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestThree&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;

    &lt;test name=&quot;threadXml_B&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestSecond&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;
&lt;/suite&gt;
</code></pre>
<p><strong>结果</strong></p>
<pre><code class="result">ThreadByXmlTestSecond ## 方法一：14
ThreadByXmlTestFirst ## 方法一：13

ThreadByXmlTestSecond ## 方法二：14
ThreadByXmlTestFirst ## 方法二：13

ThreadByXmlTestThree ## 方法一：13
ThreadByXmlTestThree ## 方法二：13</code></pre>
<blockquote>
<p>ThreadByXmlTestFirst和ThreadByXmlTestThree都在<code>threadXml_A</code>中，所有它们的测试方法都一个线程来run</p>
</blockquote>
<h4 id="5-2-3-classes"><a href="#5-2-3-classes" class="headerlink" title="5-2-3.classes"></a>5-2-3.classes</h4><p>同一classes下的类里所有方法都用一个线程来run。</p>
<p><strong>配置</strong></p>
<pre><code class="xml">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot; &gt;

&lt;suite name=&quot;testSuite&quot; verbose=&quot;1&quot; parallel=&quot;classes&quot; thread-count=&quot;5&quot;&gt;

    &lt;test name=&quot;threadXml_A&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestFirst&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestThree&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;

    &lt;test name=&quot;threadXml_B&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestFirst&quot;/&gt;
            &lt;class name=&quot;com.iworkh.testng.demo.thread.ThreadByXmlTestSecond&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;
&lt;/suite&gt;</code></pre>
<p><strong>结果</strong></p>
<pre><code class="result">ThreadByXmlTestThree ## 方法一：14
ThreadByXmlTestFirst ## 方法一：13

ThreadByXmlTestFirst ## 方法二：13
ThreadByXmlTestThree ## 方法二：14

ThreadByXmlTestFirst ## 方法一：15
ThreadByXmlTestSecond ## 方法一：16

ThreadByXmlTestFirst ## 方法二：15
ThreadByXmlTestSecond ## 方法二：16</code></pre>
<blockquote>
<p>不同的类，不同的线程执行</p>
</blockquote>
<h3 id="5-3-注解多线程"><a href="#5-3-注解多线程" class="headerlink" title="5-3.注解多线程"></a>5-3.注解多线程</h3><pre><code class="java">@Test(threadPoolSize = 2, invocationCount = 2)
public class ThreadByAnnoTest {

    public void testOne() {
        System.out.println(&quot;方法一：&quot; + Thread.currentThread().getId());
    }

    @Test(threadPoolSize = 3, invocationCount = 3)
    public void testTwo() {
        System.out.println(&quot;方法二：&quot; + Thread.currentThread().getId());
    }
}</code></pre>
<blockquote>
<p>通过<code>@Test</code>的两个属性<code>threadPoolSize</code>和<code>invocationCount</code>,分别指线程数和执行次数<br>注意：方法上的属性会替换调方法上的属性</p>
</blockquote>
<p><strong>结果:</strong></p>
<pre><code class="result">方法一：12
方法一：11

方法二：13
方法二：14
方法二：15</code></pre>
<h2 id="6-报告"><a href="#6-报告" class="headerlink" title="6.报告"></a>6.报告</h2><p><strong>testng常见测试报告</strong></p>
<ul>
<li>TestNg报告</li>
<li>ReportNg报告 <a href="https://www.jianshu.com/p/20f82c961632" target="_blank" rel="noopener">Rest Assured+TestNg实现数据驱动的接口测试</a></li>
<li>ExtentReport报告 <a href="https://www.jianshu.com/p/ac9076108f32" target="_blank" rel="noopener">ExtentReports开源框架探索</a></li>
<li>Allure报告 <a href="https://www.jianshu.com/p/202442454b02" target="_blank" rel="noopener">Allure开源框架探索》</a></li>
<li>ztest</li>
</ul>
<p><strong>一些扩展链接</strong></p>
<ul>
<li><a href="https://www.jianshu.com/p/20f82c961632" target="_blank" rel="noopener">Rest Assured+TestNg实现数据驱动的接口测试</a></li>
<li><a href="https://www.jianshu.com/p/ac9076108f32" target="_blank" rel="noopener">ExtentReports开源框架探索</a></li>
<li><a href="https://www.jianshu.com/p/202442454b02" target="_blank" rel="noopener">Allure开源框架探索》</a></li>
<li><a href="https://blog.csdn.net/lykio_881210/article/details/79206645" target="_blank" rel="noopener">testng-xslt美化testng测试报告</a></li>
<li><a href="https://reportng.uncommons.org/" target="_blank" rel="noopener">ReportN官网</a></li>
<li><a href="https://testerhome.com/topics/2180" target="_blank" rel="noopener">ReportNG 手把手教你弄测试报告</a></li>
<li><a href="https://github.com/zhangfei19841004/ztest" target="_blank" rel="noopener">ztest github源码</a></li>
</ul>
<h3 id="6-1-ExtentReport报告"><a href="#6-1-ExtentReport报告" class="headerlink" title="6-1.ExtentReport报告"></a>6-1.ExtentReport报告</h3><p>有的文章使用的是<code>testng-extentsreport</code>来出的报告，有兴趣的可以参照下这篇blog <a href="https://www.jianshu.com/p/33eb4f110ab7" target="_blank" rel="noopener">ExtentReport测试报告</a></p>
<p>本篇使用的是<code>extentreports-testng-adapter</code>来出的报告。具体步骤如下：</p>
<ul>
<li><a href="http://extentreports.com/" target="_blank" rel="noopener">extentreports官网</a></li>
<li><a href="http://extentreports.com/docs/versions/4/java/" target="_blank" rel="noopener">extentreports文档4版本</a></li>
<li><a href="http://extentreports.com/docs/versions/4/java/testng.html" target="_blank" rel="noopener">extentreports文档4和testng进行整合</a></li>
</ul>
<blockquote>
<p>通过<code>extentreports文档4和testng进行整合</code>介绍，我们知道ExtentReport的社区版和专业版的依赖是不一样的。我们使用社区版来演示学习。</p>
</blockquote>
<p><strong>添加依赖</strong></p>
<pre><code class="xml">&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.testng&lt;/groupId&gt;
        &lt;artifactId&gt;testng&lt;/artifactId&gt;
        &lt;version&gt;6.14.3&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.aventstack&lt;/groupId&gt;
        &lt;artifactId&gt;extentreports&lt;/artifactId&gt;
        &lt;version&gt;4.1.7&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.aventstack&lt;/groupId&gt;
        &lt;artifactId&gt;extentreports-testng-adapter&lt;/artifactId&gt;
        &lt;version&gt;1.0.7&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;</code></pre>
<blockquote>
<p>这里使用的是<code>4.1.7</code>，目前最新版本已经<code>5.x</code>，但是要跟我们选的testng的版本对应，所以选中了<code>4.1.7</code>。要注意版本之间的兼容问题。</p>
</blockquote>
<ul>
<li>ExtentITestListenerClassAdapter：每执行完一个Test更新一次报告</li>
<li>ExtentITestListenerAdapter：每执行完一个Test更新一次报告</li>
<li>ExtentIReporterSuiteClassListenerAdapter：每执行完一个suite更新一次报告</li>
<li>ExtentIReporterSuiteListenerAdapter：每执行完一个suite更新一次报告</li>
</ul>
<p><strong>测试类</strong></p>
<pre><code class="java">public class ReportTest {

    @Test
    public void testFail(){
        System.out.println(&quot;fail&quot;);
        Assert.assertTrue(false);
    }

    @Test
    public void testPass(){
        System.out.println(&quot;pass&quot;);
        Assert.assertTrue(true);
    }
}</code></pre>
<p><strong>report配置文件</strong></p>
<pre><code class="java">extent.reporter.html.start=true
extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html</code></pre>
<p><strong>test-ng的配置</strong></p>
<pre><code class="xml">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot; &gt;

&lt;suite name=&quot;testSuite&quot; verbose=&quot;1&quot;&gt;
    &lt;listeners&gt;
        &lt;listener class-name=&quot;com.aventstack.extentreports.testng.listener.ExtentITestListenerClassAdapter&quot;/&gt;
    &lt;/listeners&gt;
    &lt;test name=&quot;report&quot;&gt;
        &lt;classes&gt;
            &lt;class name=&quot;com.iworkh.testng.report.ReportTest&quot;/&gt;
        &lt;/classes&gt;
    &lt;/test&gt;
&lt;/suite&gt;</code></pre>
<blockquote>
<p>跑完testng报告，然后去<code>test-output/HtmlReport/ExtentHtml.html</code>目录下查看对应的<code>ExtentHtml.html</code>报告</p>
</blockquote>
<h3 id="6-2-Allure报告"><a href="#6-2-Allure报告" class="headerlink" title="6-2.Allure报告"></a>6-2.Allure报告</h3><ul>
<li><a href="https://docs.qameta.io/allure/#_installing_a_commandline" target="_blank" rel="noopener">官网</a></li>
</ul>
<p>这只介绍如何开发本地玩，至于如何集成到jenkins中，可以查看官网步骤。 <a href="https://docs.qameta.io/allure/#_jenkins" target="_blank" rel="noopener">集成Jenkins</a></p>
<p><strong>共以下几个步骤：</strong></p>
<ul>
<li>下载allure-commandline，根据自己系统，下载并安装 <a href="https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/" target="_blank" rel="noopener">allure-commandline下载地址</a></li>
<li>配置allure环境变量(我的电脑 - 高级系统设置 - 高级 - 环境变量 - path - 添加bin目录到path中)。然后命令行验证<code>allure --version</code></li>
<li>编写代码，配置maven插件</li>
<li><code>mvn clean test</code>生成报告</li>
<li>启动allure-commandline,<code>allure serve ./allure-results</code>(注意测试报告位置), 然后查看生成的报告</li>
</ul>
<p><strong>a.生成报告</strong></p>
<pre><code class="shell">mvn clean test</code></pre>
<img src="/blog/images/java/testng/testng-report-allure-gen.png" width="450px">


<p><strong>b.命令启动</strong></p>
<pre><code class="shell">allure serve ./allure-results</code></pre>
<img src="/blog/images/java/testng/testng-report-allure-start.png" width="650px">


<p><strong>c.报告结果</strong></p>
<img src="/blog/images/java/testng/testng-report-allure-html.png" width="650px">

      
       <hr><span style="font-style: italic;color: gray;"> 转载请注明来源，欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论，也可以邮件至 157162006@qq.com </span>
    </div>
</article>


<p>
    <a  class="dashang" onclick="dashangToggle()">赏</a>
</p>


<div class="article_copyright">
    <p><span class="copy-title">文章标题:</span>👍TestNG一篇足以</p>
    <p><span class="copy-title">字数:</span><span class="post-count">5k</span></p>
    <p><span class="copy-title">本文作者:</span><a  title="沐雨云楼">沐雨云楼</a></p>
    <p><span class="copy-title">发布时间:</span>2020-08-22, 18:37:28</p>
    <p><span class="copy-title">最后更新:</span>2020-09-12, 21:21:47</p>
    <span class="copy-title">原始链接:</span><a class="post-url" href="/blog/2020/08/22/java-test-ng/" title="👍TestNG一篇足以">https://iworkh.gitee.io/blog/2020/08/22/java-test-ng/</a>
    <p>
        <span class="copy-title">版权声明:</span><i class="fa fa-creative-commons"></i> <a rel="license noopener" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" title="CC BY-NC-SA 4.0 International" target = "_blank">&#34;署名-非商用-相同方式共享 4.0&#34;</a> 转载请保留原文链接及作者。
    </p>
</div>



    <div id="comments"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">

<script type="text/javascript">
    $.getScript('/blog/js/gitalk.js', function () {
        var gitalk = new Gitalk({
            clientID: 'e4a269e1ae1600031361',
            clientSecret: '6f3f981cbc49dd802fde779697d8f01da3a77981',
            repo: 'iworkh.github.io',
            owner: 'iworkh',
            admin: ['iworkh'],
            id: decodeURI(location.pathname),
            distractionFreeMode: 'true',
            language: 'zh-CN',
            perPage: parseInt('10',10)
        })
        gitalk.render('comments')
    })
</script>




    




    </div>
    <div class="copyright">
        <p class="footer-entry">©2020 iworkh</p>
<!--<p class="footer-entry">Built with <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/yelog/hexo-theme-3-hexo" target="_blank">3-hexo</a> theme</p>-->

    </div>
    <div class="full-toc">
        <button class="full" data-title="切换全屏 快捷键 s"><span class="min "></span></button>
<button class="post-toc-menu" data-title="打开TOC 快捷键 w"><span class="post-toc-menu-icons"></span></button>
<div class="post-toc"><span class="post-toc-title">目录</span>
    <div class="post-toc-content">

    </div>
</div>
<a class="" id="rocket" ></a>

    </div>
</div>
<div class="acParent"></div>

<div class="hide_box" onclick="dashangToggle()"></div>
<div class="shang_box">
    <a class="shang_close"  onclick="dashangToggle()">×</a>
    <div class="shang_tit">
        <p>喜欢就点赞,疼爱就打赏</p>
    </div>
    <div class="shang_payimg">
        <div class="pay_img">
            <img src="/blog/img/alipay.jpg" class="alipay" title="扫码支持">
            <img src="/blog/img/weixin.jpg" class="weixin" title="扫码支持">
        </div>
    </div>
    <div class="shang_payselect">
        <span><label><input type="radio" name="pay" checked value="alipay">支付宝</label></span><span><label><input type="radio" name="pay" value="weixin">微信</label></span>
    </div>
</div>


</body>
<script src="/blog/js/jquery.pjax.js?v=1.0.1" ></script>

<script src="/blog/js/script.js?v=1.0.1" ></script>
<script>
    var img_resize = 'default';
    /*作者、标签的自动补全*/
    $(function () {
        $('.search').AutoComplete({
            'data': ['@沐雨云楼','@iworkh','#ai','#attr','#aysnc','#beanmap','#bigdecimal','#blog','#chrome','#dict','#dll','#docker','#domain','#fastjson','#func','#git','#github','#hadoop','#hexo','#idea','#iworkh','#jackson','#java','#jdni','#jfinalshell','#joplin','#JPA','#lock','#markdowm','#maven','#mock','#mq','#mycat','#mysql','#nginx','#notebook','#plan','#powermock','#python','#redis','#rest','#sharding-jdbc','#spark','#springboot','#test','#tool','#tools','#tornado','#transactional','#web','#windows','#wtforms','#zookeeper','#分库分表','#分页','#命令','#工具','#并发','#序列化','#微服务','#性能分析','#手册','#有道云','#标签','#模板','#百度云盘','#结构和算法','#计划','#迁移','#面试',],
            'itemHeight': 20,
            'width': 418
        }).AutoComplete('show');
    })
    function initArticle() {
        /*渲染对应的表格样式*/
        
            $(".post .pjax table").addClass("green_title");
        

        /*渲染打赏样式*/
        
        $("input[name=pay]").on("click", function () {
            if($("input[name=pay]:checked").val()=="weixin"){
                $(".shang_box .shang_payimg .pay_img").addClass("weixin_img");
            } else {
                $(".shang_box .shang_payimg .pay_img").removeClass("weixin_img");
            }
        })
        

        /*高亮代码块行号*/
        
        $('pre code').each(function(){
            var lines = $(this).text().trim().split('\n').length, widther='';
            if (lines>99) {
                widther = 'widther'
            }
            var $numbering = $('<ul/>').addClass('pre-numbering ' + widther).attr("unselectable","on");
            $(this).addClass('has-numbering ' + widther)
                    .parent()
                    .append($numbering);
            for(var i=1;i<=lines;i++){
                $numbering.append($('<li/>').text(i));
            }
        });
        

        /*访问数量*/
        
        $.getScript("//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js");
        

        /*代码高亮，行号对齐*/
        $('.pre-numbering').css('line-height',$('.has-numbering').css('line-height'));

        
        
    }

    /*打赏页面隐藏与展示*/
    
    function dashangToggle() {
        $(".shang_box").fadeToggle();
        $(".hide_box").fadeToggle();
    }
    

</script>

<!--加入行号的高亮代码块样式-->

<style>
    pre{
        position: relative;
        margin-bottom: 24px;
        border-radius: 10px;
        border: 1px solid #e2dede;
        background: #FFF;
        overflow: hidden;
    }
    code.has-numbering{
        margin-left: 30px;
    }
    code.has-numbering.widther{
        margin-left: 35px;
    }
    .pre-numbering{
        margin: 0px;
        position: absolute;
        top: 0;
        left: 0;
        width: 20px;
        padding: 0.5em 3px 0.7em 5px;
        border-right: 1px solid #C3CCD0;
        text-align: right;
        color: #AAA;
        background-color: #fafafa;
    }
    .pre-numbering.widther {
        width: 35px;
    }
</style>

<!--自定义样式设置-->
<style>
    
    
    .nav {
        width: 442px;
    }
    .nav.fullscreen {
        margin-left: -442px;
    }
    .nav-left {
        width: 120px;
    }
    
    
    @media screen and (max-width: 1468px) {
        .nav {
            width: 442px;
        }
        .nav.fullscreen {
            margin-left: -442px;
        }
        .nav-left {
            width: 150px;
        }
    }
    
    
    @media screen and (max-width: 1024px) {
        .nav {
            width: 442px;
            margin-left: -442px
        }
        .nav.fullscreen {
            margin-left: 0;
        }
        .nav .hide-list.fullscreen {
            left: 442px
        }
    }
    
    @media screen and (max-width: 426px) {
        .nav {
            width: 100%;
        }
        .nav-left {
            width: 100%;
        }
    }
    
    
    .nav-right .title-list nav a .post-title, .nav-right .title-list #local-search-result a .post-title {
        color: #383636;
    }
    
    
    .nav-right .title-list nav a .post-date, .nav-right .title-list #local-search-result a .post-date {
        color: #5e5e5f;
    }
    
    
    .nav-right nav a.hover, #local-search-result a.hover{
        background-color: #e2e0e0;
    }
    
    

    /*列表样式*/
    
    .post .pjax article .article-entry>ol, .post .pjax article .article-entry>ul, .post .pjax article>ol, .post .pjax article>ul{
        border: #e2dede solid 1px;
        border-radius: 10px;
        padding: 10px 32px 10px 56px;
    }
    .post .pjax article .article-entry li>ol, .post .pjax article .article-entry li>ul,.post .pjax article li>ol, .post .pjax article li>ul{
        padding-top: 5px;
        padding-bottom: 5px;
    }
    .post .pjax article .article-entry>ol>li, .post .pjax article .article-entry>ul>li,.post .pjax article>ol>li, .post .pjax article>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    .post .pjax article .article-entry li>ol>li, .post .pjax article .article-entry li>ul>li,.post .pjax article li>ol>li, .post .pjax article li>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    

    /* 背景图样式 */
    
    


    /*引用块样式*/
    

    /*文章列表背景图*/
    

    
</style>






<div class="mobile-menus-out" >

</div>
<div class="mobile-menus">
    
    
    
    <a class="dynamic-menu " target="_blank"  href="https://pgmanor.gitee.io/blog/">pgmanor</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://www.iworkh.com/manualIt/Category/scopeDev/">iworkh</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://gitee.com/iworkh">gitee</a>
    
</div>


<div style="position:absolute; bottom: 0; right: 0;">
    <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=150 height=40 src="//music.163.com/outchain/player?type=2&id=1323150930&auto=0&height=32"></iframe>
</div>

</html>
